package com.matrix.java.chap_07;

import java.util.Scanner;

/*
    找出最小元素的下标
 */
public class Ex7_10 {
    public static void main(String[] args) {
        double[] array = new double[10];
        Scanner input = new Scanner(System.in);
        System.out.print("Enter ten numbers: ");
        for (int i = 0; i < array.length; i++) {
            array[i] = input.nextDouble();
        }
        input.close();
        System.out.println("最小元素的下标: " + indexOfSmallestElement(array));
    }

    public static int indexOfSmallestElement(double[] array) {
        int subscript = 0;
        double min = array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i] < min) {
                subscript = i;
                min = array[i];
            }
        }
        return subscript;
    }
}
